package com.zmz.Stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2022/07/31/19:06
 * @Description:  joining 可以将stream中的元素用特定的连接符（没有的话，则直接连接）连接成一个字符串
 */
public class Stream11 {
    public static void main(String[] args) {
        List<Person> personList = new ArrayList<>();
        personList.add(new Person("的撒", 8000, 22, "女", "武汉"));
        personList.add(new Person("法按时", 7000, 22, "女", "武汉"));
        personList.add(new Person("的阿萨", 7800, 22, "男", "武汉"));
        personList.add(new Person("答案", 12000, 12, "女", "武汉"));
        personList.add(new Person("滴放", 22000, 21, "女", "北京"));
        //找出所有的名字，并按， 进行分割，最后返回一个使用，分割好的字符串
        String nameStr= personList.stream().map(t->t.getName()).collect(Collectors.joining(","));
        System.out.println(nameStr);
        //输出a-b-c
        List<String> list = Arrays.asList("a","b","c");
        System.out.println(list.stream().collect(Collectors.joining("-")));
    }
}
